﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace team1337blarg
{
    class ArrowSprite
    {

        public void CheckIfOnScreen(int maxWidth, int maxHeight, MySprite theCharacter)
        {//keeps the arrow sprite in the window
            if (this.directionFired == 1)
            {
                this.screenPositionX = theCharacter.screenPositionX - this.arrowWidth;
                this.screenPositionY = theCharacter.screenPositionY + theCharacter.spriteHeight;
            }
            if (this.directionFired == 2)
            {
                this.screenPositionX = theCharacter.screenPositionX + (theCharacter.spriteWidth / 2) - (this.arrowWidth / 2);
                this.screenPositionY = theCharacter.screenPositionY + theCharacter.spriteHeight;
            }
            if (this.directionFired == 3)
            {
                this.screenPositionX = theCharacter.screenPositionX + theCharacter.spriteWidth;
                this.screenPositionY = theCharacter.screenPositionY + theCharacter.spriteHeight;
            }
            if (this.directionFired == 4)
            {
                this.screenPositionX = theCharacter.screenPositionX - this.arrowWidth;
                this.screenPositionY = theCharacter.screenPositionY + (theCharacter.spriteHeight / 2) - (this.arrowHeight / 2);
            }
            if (this.directionFired == 6)
            {
                this.screenPositionX = theCharacter.screenPositionX + theCharacter.spriteWidth;
                this.screenPositionY = theCharacter.screenPositionY + (theCharacter.spriteHeight / 2) - (this.arrowHeight / 2);
            }
            if (this.directionFired == 7)
            {
                this.screenPositionX = theCharacter.screenPositionX - this.arrowWidth;
                this.screenPositionY = theCharacter.screenPositionY - this.arrowHeight;
            }
            if (this.directionFired == 8)
            {
                this.screenPositionX = theCharacter.screenPositionX + (theCharacter.spriteWidth / 2) - (this.arrowWidth / 2);
                this.screenPositionY = theCharacter.screenPositionY - this.arrowHeight;
            }
            if (this.directionFired == 9)
            {
                this.screenPositionX = theCharacter.screenPositionX + theCharacter.spriteWidth;
                this.screenPositionY = theCharacter.screenPositionY - this.arrowHeight;
            }

        }

        public void StandardArrow(int numpressed)
        {//standard arrow constructor
            if (numpressed == 1)
            {
                arrowStartX = 72;
                arrowStartY = 1;
                arrowWidth = 8;
                arrowHeight = 8;
            }
            if (numpressed == 2)
            {
                arrowStartX = 34;
                arrowStartY = 1;
                arrowWidth = 6;
                arrowHeight = 11;
            }
            if (numpressed == 3)
            {
                arrowStartX = 63;
                arrowStartY = 1;
                arrowWidth = 8;
                arrowHeight = 8;
            }
            if (numpressed == 4)
            {
                arrowStartX = 14;
                arrowStartY = 2;
                arrowWidth = 11;
                arrowHeight = 6;
            }
            if (numpressed == 6)
            {
                arrowStartX = 1;
                arrowStartY = 2;
                arrowWidth = 11;
                arrowHeight = 6;
            }
            if (numpressed == 7)
            {
                arrowStartX = 42;
                arrowStartY = 1;
                arrowWidth = 8;
                arrowHeight = 8;
            }
            if (numpressed == 8)
            {
                arrowStartX = 26;
                arrowStartY = 1;
                arrowWidth = 6;
                arrowHeight = 11;
            }
            if (numpressed == 9)
            {
                arrowStartX = 53;
                arrowStartY = 1;
                arrowWidth = 8;
                arrowHeight = 8;
            }

            speed = 10;
            isAway = false;
            deleteThis = false;
            directionFired = numpressed;
        }

        public void updateDirection(MySprite theCharacter)
        {//moves the arrow while isAway
            if (this.directionFired == 1)
            {
                this.screenPositionX -= (int)((0.707106781) * this.speed);
                this.screenPositionY += (int)((0.707106781) * this.speed);
            }
            if (this.directionFired == 2)
            {
                this.screenPositionY += this.speed;
            }
            if (this.directionFired == 3)
            {
                this.screenPositionX += (int)((0.707106781) * this.speed);
                this.screenPositionY += (int)((0.707106781) * this.speed);
            }
            if (this.directionFired == 4)
            {
                this.screenPositionX -= this.speed;
            }
            if (this.directionFired == 6)
            {
                this.screenPositionX += this.speed;
            }
            if (this.directionFired == 7)
            {
                this.screenPositionX -= (int)((0.707106781) * this.speed);
                this.screenPositionY -= (int)((0.707106781) * this.speed);
            }
            if (this.directionFired == 8)
            {
                this.screenPositionY -= this.speed;
            }
            if (this.directionFired == 9)
            {
                this.screenPositionX += (int)((0.707106781) * this.speed);
                this.screenPositionY -= (int)((0.707106781) * this.speed);
            }
        }

        public int arrowStartX;
        public int arrowStartY;
        public int arrowWidth;
        public int arrowHeight;
        public int screenPositionX;
        public int screenPositionY;
        public int speed;
        public int directionFired;
        /*
         * directionFired value is the same as the numpad key pressed to fire it in that direction
         * value 5 may later be used for reload button or cancel fire arrow button
         * 1 = bottom left arrow
         * 2 = bottom arrow
         * 3 = bottom right arrow
         * 4 = left arrow
         * 6 = right arrow
         * 7 = top left arrow
         * 8 = top arrow
         * 9 = top right arrow
        */
        public bool isAway;
        public bool deleteThis;

    }
}
